<?php
//当前控制器的命名空间，对应Application\Admin\Controller目录
namespace Admin\Controller;
//引入的命名空间
use Think\Controller;
//Admin模块Index控制器
class SuperformController extends Controller {


 //验证码生成
    public function verify_c(){  
        $Verify = new \Think\Verify();  
        $Verify->fontSize = 18;  
        $Verify->length   = 4;  
        $Verify->useNoise = false;  
        $Verify->codeSet = 'abcdefghij';  
        $Verify->imageW = 130;  
        $Verify->imageH = 50;  
        //$Verify->expire = 600;  
        $Verify->entry();  
    }

     //超级管理员 登录
    public function login_superadmin($suadnameA = '', $supasswordA = ''){
    $suadnameA = $_POST['suadnameA'];
    $supasswordA = $_POST['supasswordA'];
    $verify = $_POST['verify'];
    //验证码检测
    if(!check_verify($verify)){  
    $this->error("验证码输错了哦！");
    }
    //验证中...
    $Data = M('Superadmin');
    $result = $Data->where("suadname='" . $suadnameA . "' AND supassword='" . $supasswordA . "'")->find();

    if($result){
        session('suadnameA',$suadnameA);
        $_SESSION['uid'] = $result['uid'];
        $this->success('登录成功！',U('/Admin/superindex'));//若提交完成则显示成功消息
    }else{
        $this->error('用户名或密码错误！');//否则提示
    }
    }
    //超级管理员 退出登录
    public function logout(){
        if(isset($_SESSION['suadnameA'])){
            session('suadnameA',null);
            session('[destroy]');
            $this->success('用户已退出！', U('/Admin/Superform/superlogin'));
        }else{
            $this->redirect('/Admin/Superform/superlogin');
        }
    }
    

    
    
    
}